﻿var PropertyConfig = {
    'Start': [{
        'id': 'BaseProperty',
        'description': '基本设置',
        'js': 'BaseProperty'
    }],
    'End': [{
        'id': 'BaseProperty',
        'description': '基本设置',
        'js': 'BaseProperty'
    }],

    'Drafting': [{
        'id': 'BaseProperty',
        'description': '基本设置',

        'js': 'BaseProperty'
    },
       {
           'id': 'UserProperty',
           'description': '人员设置',
           'js': 'UserProperty'
       }],
    'Approval': [{
        'id': 'BaseProperty',
        'description': '基本设置',
        'js': 'BaseProperty'
    },
     {
         'id': 'UserProperty',
         'description': '人员设置',
         'js': 'UserProperty'
     },
     {
         'id': 'ReturnProperty',
         'description': '回退设置',
         'js': 'ReturnProperty'
     }],

    'Freedom': [{
        'id': 'BaseProperty',
        'description': '基本设置',
        'js': 'BaseProperty'
    },
       {
           'UserProperty': 'UserProperty',
           'description': '人员设置',
           'js': 'UserProperty'
       },
     {
         'id': 'ReturnProperty',
         'description': '回退设置',
         'js': 'ReturnProperty'
     }],
    'Condition': [{
        'id': 'BaseProperty',
        'description': '基本设置',
        'js': 'BaseProperty'
    }],
    'Merging': [{
        'id': 'BaseProperty',
        'description': '基本设置',
        'js': 'BaseProperty'
    }],
    'Branching': [{
        'id': 'BaseProperty',
        'description': '基本设置',
        'js': 'BaseProperty'
    }]
}

var Reflection = {
    'BaseProperty': BaseProperty,
    'UserProperty': UserProperty,
    'ReturnProperty': ReturnProperty,
    'ReminderProperty': ReminderProperty
}


var Property = {
    InitailProperty: function (activity) {
        $("#divActivityProp").empty().css("height", "330px");

        var container = $("<div style=' margin:10px;'>").attr("class", "demoWrapper");
        var tabNav = $("<div id='tabNav'>");
        container.append(tabNav);
        var ul = $("<div class='tabContainer' style=' margin-left:5px;' >");
        tabNav.append(ul);
        var tabs = $("  <div class='tabContent'  style=' width:658px; height:290px'>");
        tabNav.append(tabs);
        tmp = 0;
        var activityType = activity.GetActivityTypeName()
        var tmp = 0;
        $.each(PropertyConfig[activityType], function (i, val) {
            var listring = tmp == 0 ? "<div  class='tabSelected' style='text-align:center;'>" + val.description + "</div>" :
                 "<div  class='tabUnselected' style='text-align:center;'>" + val.description + "</div>";
      
            var li = $(listring);
            ul.append(li);


            var baseproperty = $(" <div id='" + val.id + "'class='tab' style=' height:290px; width:100%'></div>");
            Reflection[val.js]["InitialPage"](baseproperty, activity);
            tabs.append(baseproperty);
            if (tmp == 0)
                baseproperty.css("display", "block");
            else baseproperty.css("display", "none");
            baseproperty.unbind();

            li.click(function () {
                $(".tab").css("display", "none");
                baseproperty.css("display", "block");
                $(".tabSelected").attr("class", "tabUnselected");
                var me = this;
                me.setAttribute("class", "tabSelected");
                li.find('a').click();
            })
            ++tmp;
        });
        $("#divActivityProp").append(container);
        $("#tabNav ul").idTabs("BaseProperty");
        return $("#root");
    },

    SaveData: function (activity) {
        var activityType = activity.GetActivityTypeName()
        $.each(PropertyConfig[activityType], function (i, val) {
            Reflection[val.js].SaveData(activity);
        });
        ToolBar.HistroyOpertion();
    }

}